

using System;
using System.Collections.Generic;
using System.Text;

namespace JTC.MiniCommerce.Core {
  public partial class ConfigurationDatumController {

    #region Constants

    private const string CONFIGURATION_SECTION_NAME = "configurationSectionName";
    
    #endregion
    
    #region Methods
    
    #region Public

    /// <summary>
    /// Fetches the configuration by name.
    /// </summary>
    /// <param name="configurationSectionName">Name of the configuration section.</param>
    /// <returns></returns>
    public ConfigurationDatum FetchConfigurationByName(string configurationSectionName) {
      Validator.ValidateStringArgumentIsNotNullOrEmptyString(configurationSectionName, CONFIGURATION_SECTION_NAME);

      ConfigurationDatumCollection configurationDatumCollection = new ConfigurationDatumCollection().
        Where(ConfigurationDatum.Columns.Name, configurationSectionName).
        Load();

      ConfigurationDatum configurationDatum = null;
      if (configurationDatumCollection.Count == 1) {
        configurationDatum = configurationDatumCollection[0];
      }
      return configurationDatum;
    }
    
    #endregion
    
    #endregion
    
  }
}
